import {LOGING,REMEMBER,USERNAME,PSWD} from '../actions/login.action';

const initLogin = {
	isLoging:false,
	isRemember:false,
	userName:'',
	passWord:''
}
let e_book_userinfo = localStorage.getItem('e_book_userinfo');
if (e_book_userinfo) {
	e_book_userinfo = JSON.parse(e_book_userinfo);
	initLogin.isRemember = e_book_userinfo.isRemember;
	initLogin.userName = e_book_userinfo.name;
	initLogin.passWord = e_book_userinfo.pswd;
}
function Login(state=initLogin,action) {

	switch (action.type){
		case LOGING:
			state.isLoging = action.isLoging;
			return {...state};
		case REMEMBER:
			state.isRemember = action.isRemember;
			return {...state};
		case USERNAME:
			state.userName = action.name;
			return {...state};
		case PSWD:
			state.passWord = action.pswd;
			return {...state};
		default :
		return {...state};
	}
}

export default Login;